package com.demo.web.modules.sys;

import com.demo.common.constant.api.base.BaseController;
import com.demo.common.result.ResponseInfo;
import com.demo.common.result.ResultVo;
import com.demo.common.util.file.FileUploadUtils;
import com.demo.dao.sys.entity.SysCompanyItem;
import com.demo.service.sys.SysCompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/sys/company")
public class SysCompanyController extends BaseController<SysCompanyItem, Long> {
    @Autowired
    SysCompanyService sysCompanyService;

    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    public ResultVo uploadExcel(MultipartFile file){
        try{
            sysCompanyService.importExcel(file);
            return ResponseInfo.success();
        }catch (Exception ex){
            return ResponseInfo.fail("上传失败！");
        }
    }
}
